home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n05.arc / TINYDOSX.C < prev    next >
Text File  |  1991-02-13  |  1KB  |  47 lines

  1.  
  2. /*
  3.     TESTDOSX.C --- illustrates use of the DPMI-based
  4.     DOS Extender TINYDOSX to display a message in protected mode.
  5.  
  6.     Copyright (C) 1990 Ziff Davis Communications
  7.     PC Magazine * Ray Duncan
  8.  
  9.     Build with Microsoft C 6.0 SMALL MODEL as follows:
  10.  
  11.           MASM TINYDOSX;
  12.           CL TESTDOSX.C TINYDOSX
  13.  
  14.     Execute under Windows 3.0 in the DOS Box only!
  15. */
  16.  
  17. #include <stdio.h>
  18.  
  19. unsigned extern pascal InitDosX(void);
  20.  
  21. main() 
  22. {
  23.     unsigned saveCS, saveDS;
  24.  
  25.     _asm mov saveCS,cs          ; store real mode CS 
  26.     _asm mov saveDS,ds          ; and DS for display
  27.  
  28.     printf("\nHello, real mode world! \tCS=%04xh DS=%04xh", 
  29.         saveCS, saveDS);
  30.  
  31.     if(InitDosX())              // attempt mode switch
  32.     {
  33.         puts("\nDPMI initialization failed.");
  34.         exit(1);
  35.     }
  36.  
  37.     _asm mov saveCS,cs          ; store protected mode CS
  38.     _asm mov saveDS,ds          ; and DS for display
  39.  
  40.     printf("\nHello, protected mode world! \tCS=%04xh DS=%04xh\n", 
  41.         saveCS, saveDS);
  42.  
  43.     _asm mov ah,4ch             ; exit directly to DOS to avoid
  44.     _asm int 21h                ; GP fault in RTL cleanup code
  45. }
  46.  
  47.